#include "Compare.h"
#include "Helper.h"

void Compare::do_(int number, void(*custom_sort)(vector<int>&), int length, int min, int max)
{
	if (number == 0) return;

	for (int i = 0; i < number; i++)
	{
		do_(custom_sort, length, min, max);
	}
}

bool Compare::do_(void(*custom_sort)(vector<int>&), int length, int min, int max)
{
	vector<int> arr;
	random_arr(arr, length, min, max);

	vector<int>  arr1;
	arr1.assign(arr.begin(), arr.end());

	vector<int>  arr2;
	arr2.assign(arr.begin(), arr.end());

	sort(arr1.begin(), arr1.end());
	custom_sort(arr2);

	if (!do_(arr1, arr2, length))
	{
		set_font_color(FOREGROUND_RED);
		cout << "Wrong Sample: ";
		print_arr(arr, length);
		cout << "Wrong Sample Sort:";
		print_arr(arr2, length);
		set_font_color(FOREGROUND_GREEN);
		cout << "right Sample Sort:";
		print_arr(arr1, length);
		cout << endl;
		return false;
	}
	else
	{
		set_font_color(FOREGROUND_GREEN);
		cout << "Right Sample: ";
		print_arr(arr, length);
		cout << "Right Sample Sort: ";
		print_arr(arr2, length);
		cout << endl;
	};

	set_font_color(0x07);
	return true;
}

bool Compare::do_(vector<int>& arr1, vector<int>& arr2, int length)
{
	bool right = true;
	for (int i = 0; i < length; i++)
	{
		if (arr1[i] == arr2[i])
		{

		}
		else
		{
			right = false;
		};
	}
	return right;
}
